﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using TestApi.Services;

namespace TestApi.Controllers
{
    [Route("[controller]")]
    [ApiController]
    public class TestController : ControllerBase
    {

        private readonly ILogger<TestController> _logger;
        private readonly TestService testService;

        public TestController(ILogger<TestController> logger, TestService testService)
        {
            _logger = logger;
            this.testService = testService;
        }

        [HttpPost]
        [Route("Loading")]
        public async Task<ResultDto> Loading(string name= "idcf-boat-house")
        {
            if (string.IsNullOrEmpty(name))
                throw new Exception("仓库名称不能为空");
          return  await testService.Loading(name);
        }


        [HttpPost]
        [Route("Left")]
        public async Task<ResultDto> Left(List<RightDto> rights)
        {
            if (rights == null)
                throw new Exception("参数不能为空");
            return await testService.Left(rights);
        }

        [HttpPost]
        [Route("Right")]
        public async Task<ResultDto> Right(List<LeftDto> lefts)
        {
            if (lefts == null)
                throw new Exception("参数不能为空");
            return await testService.Right(lefts);
        }

        [HttpPost]
        [Route("Email")]
        public async Task<string> Email()
        {
            return await testService.Email();
        }
    }
}
